<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #box{
            width: 200px;
            height: 200px;
            border: 1px solid #ccc;
            margin: 100px auto;
            color: yellow;
        }
        p{
            width: 200px;
            height: 200px;
            border: 1px solid #ccc;
            margin: 0 auto;
        }
        .demo{
            width: 200px;
            height: 200px;
            border: 1px solid #ccc;
            margin: 100px auto;
        }

    </style>
</head>
<body>
    <div id="box">hello wold</div>
    <div id="box1">hello wold</div>
    <div id="box">hello wold</div>
    <p>hello</p>
    <p>hello</p>
    <p>hello</p>
    <div class="demo"></div>
    <div class="demo"></div>
    <div class="demo"></div>
    <div class="demo"></div>
</body>
</html>
<script src="js/jquery-1.10.1.js"></script>
<script>
    $(function () {
        $("#box").css("background","purple")
       //获取id为box选择器的个数
        alert($("#box").size());  //返回id选择器的个数
       //获取标签为p的选择器的 个数
        alert($("p").size());    //返回为p的选择器的 个数
        //获取class为demo的选择器的个数
        alert($(".demo").size());
        alert($(".demo").length);  //返回取class为demo的选择器的个数
    })
</script>